﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ElectronicWMSA.Comm.ClassFiles;
using SYDZ.WMS.DBUtility;

namespace ElectronicWMSA.Warehouse
{
    public partial class List_StockUpdateOptionFrm : Form
    {
        private string Option_NID = "0";
        private string NUM1 = "0";
        private string NUM2 = "0";
        public List_StockUpdateOptionFrm(string _NID)
        {
            InitializeComponent();
            Option_NID = _NID;
        }
        private void FrmplanSee_Load(object sender, EventArgs e)
        {
            if (Option_NID != "0" && Option_NID != "")
            {
                string sql_Info = " SELECT TOP 1 PutList_NO,Product_Model,BK03,BK06 FROM [DB_WMSFIRST].[dbo].[T_Stock] where NID=" + Option_NID + "";
                DataTable dt = new DataTable();
                dt = DbHelperSQL.Query(sql_Info).Tables[0];

                NUM1 = dt.Rows[0][3].ToString();
                txt_Rukunum.Text = dt.Rows[0][0].ToString();
                txt_Machine.Text = dt.Rows[0][1].ToString();
                txtType.Text = dt.Rows[0][2].ToString();
                txt_number.Text = dt.Rows[0][3].ToString();
            }
        }
   
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                NUM2 = txt_number.Text.Trim();
                if (!ValidationRegex.ValidteData(NUM2))
                {
                    MessageBox.Show("输入数量不正确！");
                    txt_number.Focus();
                    return;
                }
                if (MessageBox.Show("确认修改内容？", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string sql_Update = " UPDATE [DB_WMSFIRST].[dbo].[T_Stock] SET BK06='" + NUM2 + "' WHERE NID=" + Option_NID + " ";
                    DbHelperSQL.GetSingle(sql_Update);

                    SystemVariable.AddLogInfo("灯泡在库调整", "操作员：【" + SystemVariable.Login_Name + "】操作机型:" + txt_Machine.Text.Trim() + "在库数量调整：【" + NUM1 + "】—【" + NUM2 + "】");

                    MessageBox.Show("操作成功！");
                }
            }
            catch
            {
                MessageBox.Show("操作失败！");
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
